import React, { useCallback } from 'react';
import { loginFn } from '../../store/actions'
import { IStoreState } from '../../store'
import { connect } from 'react-redux'

interface Iprops {
  dispatch: any,
  info: any
}
const Login: React.FC<Iprops> = function (props) {
  const login = useCallback(() => {
    props.dispatch(loginFn({
      username: '张三', userpsw: '55554546'
    }))

  }, [])
  return <div className=''>
    登录页{JSON.stringify(props.info)}
    <button onClick={login}>登录</button>
  </div>;
}
// class Login extends React.Component {
//   render() {
//     return <div className=''>
//       登录页
//       <button onClick={thi}>登录</button>
//         </div>;
//   }
// }
export default connect((state: IStoreState) => {
  return {
    info: state.userInfo
  }
}, (dispatch) => {
  return {
    dispatch
  }
})(Login)